package com.example.aoporder;

import com.example.aoporder.service.OrderService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class AopOrderApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext ctx =
                SpringApplication.run(AopOrderApplication.class, args);
        OrderService service = ctx.getBean(OrderService.class);

        try {
            service.add("iPhone", 2);
        } catch (Exception ignore) {}

        try {
            service.delete("iPhone");
        } catch (Exception ignore) {}

        int remain = service.find("iPhone");
        System.out.println("购物车剩余 iPhone 数量: " + remain);
    }
}